package com.lkd.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lkd.base.BaseController;
import com.lkd.base.ResponseResult;
import com.lkd.domain.Sku;
import com.lkd.domain.VmType;
import com.lkd.pageParam.SkuPageParam;
import com.lkd.pageParam.VmTypePageParam;
import com.lkd.service.IVmTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.lkd.base.ResponseResult.success;

/**
 * <p>
 * 售货机类型表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-02-12
 */
@RestController
@Api("设备类型管理相关接口")
@RequestMapping("/vm-type")
public class VmTypeController extends BaseController {
    @Autowired
    private IVmTypeService vmTypeService;
    @ApiOperation("设备类型搜索")
    @GetMapping("/search")
    public ResponseResult<Page<VmType>> search(VmTypePageParam param){
        Page<VmType> page =  vmTypeService.getPage(param);
        return success(page);
    }
    @ApiOperation("新增设备类型")
    @PostMapping("/add")
    public ResponseResult add(@RequestBody VmType vmType){
          vmTypeService.save(vmType);
        return success();
    }
    @ApiOperation("修改设备类型")
    @PutMapping("/typeId/{typeId}")
    public ResponseResult update(@PathVariable Long typeId,@RequestBody VmType vmType){
        vmTypeService.updateById(vmType);
        return success();
    }
    @ApiOperation("删除设备类型")
    @DeleteMapping("/typeId")
    public ResponseResult update(@PathVariable Long typeId){
        vmTypeService.removeById(typeId);
        return success();
    }
}
